﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="img/logo.png">
<title>博客后台-写文章</title>

<link rel="stylesheet" href="plugin/layui/css/layui.css">
<link rel="stylesheet" href="css/back.css">
<link rel="stylesheet"
	href="plugin/font-awesome/css/font-awesome.min.css">
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">
				<a href="/admin" style="color: #009688;"> 个人博客后台 </a>
			</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<ul class="layui-nav layui-layout-left">
				<li class="layui-nav-item"><a href="/" target="_blank">前台</a></li>
				<li class="layui-nav-item"><a href="javascript:;">新建</a>
					<dl class="layui-nav-child">
						<dd>
							<a href="/admin/article/insert">文章</a>
						</dd>
						<dd>
							<a href="/admin/page/insert">页面</a>
						</dd>
						<dd>
							<a href="/admin/category/insert">分类</a>
						</dd>
						<dd>
							<a href="/admin/notice/insert">公告</a>
						</dd>
						<dd>
							<a href="/admin/link/insert">链接</a>
						</dd>
					</dl></li>
			</ul>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item"><a href="javascript:;"> <img
						src="uploads/2017/10/20171006225356181.jpg" class="layui-nav-img">
						admin
				</a>
					<dl class="layui-nav-child">
						<dd>
							<a href="/admin/user/profile">基本资料</a>
						</dd>
					</dl></li>
				<li class="layui-nav-item"><a href="/admin/logout">退出</a></li>
			</ul>
		</div>

		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" lay-filter="test">
					<li class="layui-nav-item layui-nav-itemed"><a class=""
						href="javascript:;">文章</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/article">全部文章</a>
							</dd>
							<dd>
								<a href="/admin/article/insert">写文章</a>
							</dd>
							<dd>
								<a href="/admin/category">全部分类</a>
							</dd>
							<dd>
								<a href="/admin/tag">全部标签</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a href="javascript:;">页面</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/page">全部页面</a>
							</dd>
							<dd>
								<a href="/admin/page/insert">添加页面</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a class="" href="javascript:;">
							链接 </a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/link">全部链接</a>
							</dd>
							<dd>
								<a href="/admin/link/insert">添加链接</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a href="javascript:;">公告</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/notice">全部公告</a>
							</dd>
							<dd>
								<a href="/admin/notice/insert">添加公告</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a href="/admin/comment"> 评论 </a></li>
					<li class="layui-nav-item"><a class="" href="javascript:;">
							用户 </a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/user">全部用户</a>
							</dd>
							<dd>
								<a href="/admin/user/insert">添加用户</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a href="javascript:;">设置</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="/admin/menu">菜单</a>
							</dd>
							<dd>
								<a href="/admin/options">主要选项</a>
							</dd>
						</dl></li>
				</ul>
			</div>
		</div>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">
				<blockquote class="layui-elem-quote">
					<span class="layui-breadcrumb" lay-separator="/"> <a
						href="/admin">首页</a> <a href="/admin/article">文章列表</a> <a><cite>添加文章</cite></a>
					</span>
				</blockquote>



				<form class="layui-form" method="post" id="myForm"
					action="/admin/article/insertSubmit">

					<div class="layui-form-item">
						<label class="layui-form-label">标题 <span
							style="color: #FF5722;">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="articleTitle" lay-verify="title"
								id="title" autocomplete="off" placeholder="请输入标题"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">内容 <span
							style="color: #FF5722;">*</span></label>
						<div class="layui-input-block">
							<textarea class="layui-textarea layui-hide" name="articleContent"
								lay-verify="content" id="content"></textarea>
						</div>

					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">分类 <span
							style="color: #FF5722;">*</span>
						</label>
						<div class="layui-input-inline">
							<select name="articleParentCategoryId"
								id="articleParentCategoryId"
								lay-filter="articleParentCategoryId" required>
								<option value="" selected="">一级分类</option>
								<option value="1">Java</option>
								<option value="10">计算机科学</option>
								<option value="15">其他技术</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="articleChildCategoryId" id="articleChildCategoryId">
								<option value="" selected>二级分类</option>
							</select>
						</div>
					</div>

					<div class="layui-form-item" pane="">
						<label class="layui-form-label">标签</label>
						<div class="layui-input-block">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="Java" value="1"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="算法" value="2">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="数据结构" value="3"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="C" value="4">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="操作系统" value="5"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="计算机网络" value="6">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="面试题" value="8"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="数据库" value="9">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="MySQL" value="10"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="Spring"
								value="11"> <input type="checkbox" name="articleTagIds"
								lay-skin="primary" title="SpringMVC" value="12"> <input
								type="checkbox" name="articleTagIds" lay-skin="primary"
								title="MyBatis" value="13"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="JVM" value="14">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="设计模式" value="15"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="网络编程" value="16">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="IO" value="17"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="JSP" value="18">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="Servlet" value="19"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="JavaWeb"
								value="20"> <input type="checkbox" name="articleTagIds"
								lay-skin="primary" title="Hibernate" value="21"> <input
								type="checkbox" name="articleTagIds" lay-skin="primary"
								title="SQL" value="22"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="Redis" value="24">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="SPA" value="25"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="SpringCloud"
								value="26"> <input type="checkbox" name="articleTagIds"
								lay-skin="primary" title="Dubbo" value="27"> <input
								type="checkbox" name="articleTagIds" lay-skin="primary"
								title="EDAS" value="28"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="MongoDB"
								value="29"> <input type="checkbox" name="articleTagIds"
								lay-skin="primary" title="SpringBoot" value="31"> <input
								type="checkbox" name="articleTagIds" lay-skin="primary"
								title="ElasticSearch" value="32"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="Docker"
								value="33"> <input type="checkbox" name="articleTagIds"
								lay-skin="primary" title="Jenkins" value="34"> <input
								type="checkbox" name="articleTagIds" lay-skin="primary"
								title="Vue" value="35"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="IDEA" value="36">
							<input type="checkbox" name="articleTagIds" lay-skin="primary"
								title="Shiro" value="37"> <input type="checkbox"
								name="articleTagIds" lay-skin="primary" title="RocketMQ"
								value="38">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">状态</label>
						<div class="layui-input-block">
							<input type="radio" name="articleStatus" value="1" title="发布"
								checked> <input type="radio" name="articleStatus"
								value="0" title="草稿">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary"
								onclick="getCateIds()">重置</button>
						</div>
					</div>
					<blockquote class="layui-elem-quote layui-quote-nm">
						温馨提示：<br> 1、文章内容的数据表字段类型为MEDIUMTEXT,每篇文章内容请不要超过500万字 <br>
						2、写文章之前，请确保标签和分类存在，否则可以先新建；请勿刷新页面，博客不会自动保存 <br> 3、插入代码前，可以点击
						<a href="http://liuyanzhao.com/code-highlight.html"
							target="_blank">代码高亮</a>,将代码转成HTML格式

					</blockquote>

				</form>


			</div>
		</div>

		<div class="layui-footer">
			<!-- 底部固定区域 -->
			© 这里展示一些提示性信息 <a href="#" target="_blank">其他导航</a> / <a href="#"
				target="_blank">其他导航</a>
		</div>
	</div>

	<script src="js/jquery.min.js"></script>
	<script src="plugin/layui/layui.all.js"></script>
	<script src="js/back.js"></script>
	<script>
		layui
				.use(
						[ 'form', 'layedit', 'laydate' ],
						function() {
							var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;

							//上传图片,必须放在 创建一个编辑器前面
							layedit.set({
								uploadImage : {
									url : '/admin/upload/img' //接口url
									,
									type : 'post' //默认post
								}
							});

							//创建一个编辑器
							var editIndex = layedit.build('content', {
								height : 350,
							});

							//自定义验证规则
							form.verify({
								title : function(value) {
									if (value.length < 5) {
										return '标题至少得5个字符啊';
									}
								},
								pass : [ /(.+){6,12}$/, '密码必须6到12位' ],
								content : function(value) {
									layedit.sync(editIndex);
								}
							});

							layedit.build('content', {
								tool : [ 'strong' //加粗
								, 'italic' //斜体
								, 'underline' //下划线
								, 'del' //删除线
								, '|' //分割线
								, 'left' //左对齐
								, 'center' //居中对齐
								, 'right' //右对齐
								, 'link' //超链接
								, 'unlink' //清除链接
								, 'face' //表情
								, 'image' //插入图片
								, 'code' ]
							});

							layui.use('code', function() { //加载code模块
								layui.code();
							});

							//二级联动
							form
									.on(
											"select(articleParentCategoryId)",
											function() {
												var optionstring = "";
												var articleParentCategoryId = $(
														"#articleParentCategoryId")
														.val();

												if (articleParentCategoryId == 0) {
													optionstring += "<option name='childCategory' value='1'>Java</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='2'>Java基础</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='3'>Core Java</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='4'>多线程并发编程</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='5'>Sockets和IO</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='6'>设计模式和反射</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='7'>JVM</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='8'>JavaWeb</option>";
												}

												if (articleParentCategoryId == 1) {
													optionstring += "<option name='childCategory' value='9'>Java框架</option>";
												}

												if (articleParentCategoryId == 0) {
													optionstring += "<option name='childCategory' value='10'>计算机科学</option>";
												}

												if (articleParentCategoryId == 10) {
													optionstring += "<option name='childCategory' value='11'>数据结构和算法</option>";
												}

												if (articleParentCategoryId == 10) {
													optionstring += "<option name='childCategory' value='12'>操作系统</option>";
												}

												if (articleParentCategoryId == 10) {
													optionstring += "<option name='childCategory' value='13'>数据库</option>";
												}

												if (articleParentCategoryId == 10) {
													optionstring += "<option name='childCategory' value='14'>计算机网络</option>";
												}

												if (articleParentCategoryId == 0) {
													optionstring += "<option name='childCategory' value='15'>其他技术</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='16'>消息服务</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='17'>缓存服务</option>";
												}

												if (articleParentCategoryId == 100000000) {
													optionstring += "<option name='childCategory' value='19'>Hello</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='100000003'>微服务</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='100000004'>搜索引擎</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='100000005'>权限框架</option>";
												}

												if (articleParentCategoryId == 15) {
													optionstring += "<option name='childCategory' value='100000006'>开发利器</option>";
												}

												$("#articleChildCategoryId")
														.html(
																"<option value=''selected>二级分类</option>"
																		+ optionstring);
												form.render('select'); //这个很重要
											})

						});
	</script>

	<script>
		//给文本编辑器的iframe引入代码高亮的css
		$("iframe").contents().find("head").append(
				"<link rel=\"stylesheet\" href=\"/css/highlight.css\">\n");
	</script>

</body>
</html>
